#       - Figure ES.6, the same as Figure 3.5
#       - Figure ES.7, the same as Figure 3.17
#       - Figure ES.8, the same as Figure 3.18
### Libraries
library(haven)
library(tidyverse)
library(ggplot2)
library(ggrepel)
library(ggthemes)
### Set Up ----
# Path
## change the path to your computer here
main          <- "C:/Users/wb595552/OneDrive - WBG/Reproducibility package WBL 2024/Reproducibility package_shared"
# Directories
data_path     <- file.path(main, "DataWork/Data")
output_es     <- file.path(main, "Outputs/ExecutiveSummary")
output_c3     <- file.path(main, "Outputs/Chapter3")
### Data Clean Up ----
# Load the dataset
## change the path to your computer here
df            <- read_dta(file.path(data_path, "Final/WBL2024_Legal_Process_EOIndex.dta"))
# create Labels to highlight economies
econ_3_5      <- c("Armenia", "Bahamas, The", "Bahrain", "Bhutain", "Cambodia", "Comoros", "Latvia", "St. Lucia", #largest drop between WBL 1.0 and 2.0 per region
"Afghanistan", "Chile", "Iran, Islamic Rep.", "Italy", "Mauritius", "Panama", "Türkiye", "Viet Nam") #smallest drop between WBL 1.0 and 2.0 per region
econ_3_17     <- c("Bangladesh", "Belize", "Canada", "Jordan", "Kazakhstan", "Sudan", "Taiwan, China", #smallest implementation gap per region
"West Bank and Gaza", "United Kingdom", "Bangladesh", "Singapore", "Iran, Islamic Rep.", #additional countries above 45 degree line, or just not
"Bhutan", "Côte d'Ivoire", "Greece", "San Marino", "Suriname", "Timor-Leste", "United Arab Emirates") #largest implementation gap per region
econ_3_18     <- c("Timor-Leste", "Kosovo", "Italy", "El Salvador", "Morocco", "India", "São Tomé and Príncipe", #max difference between WBL 2.0 Legal and EO per region
"Brunei Darussalam", "Russian Federation", "Slovak Republic", "Iceland", "St. Kitts and Nevis", "Qatar", "Bhutan", "Mauritania") #min difference between WBL 2.0 Legal and EO per region
df$label_3_5  <- ifelse(df$economy %in% econ_3_5, df$economy, NA)
df$label_3_17 <- ifelse(df$economy %in% econ_3_17, df$economy, NA)
df$label_3_18 <- ifelse(df$economy %in% econ_3_18, df$economy, NA)
# order and color regions
df$region     <- gsub("High income: OECD", "OECD: High income", df$region)
desired_order <- c("East Asia & Pacific", "Europe & Central Asia", "OECD: High income",
"Latin America & Caribbean", "Middle East & North Africa", "South Asia", "Sub-Saharan Africa")
df$region     <- factor(df$region, levels = desired_order)
region_colors <- c("East Asia & Pacific" = "green", "Europe & Central Asia" = "blue", "OECD: High income" = "black",
"Latin America & Caribbean" = "red", "Middle East & North Africa" = "navy", "South Asia" = "#ADD8E6",
"Sub-Saharan Africa" = "orange")
### Figure ES.6, the same as Figure 3.5  ----
# region_shapes <- c("East Asia & Pacific" = 5, "Europe & Central Asia" = 17, "OECD: High income" = 3,
#                     "Latin America & Caribbean" = 2, "Middle East & North Africa" = 1, "South Asia" = 15,
#                    "Sub-Saharan Africa" = 16)
lm_model1 <- lm(Legal_Index_old ~ Legal_Index_LegNew, data = df)
summary_lm1 <- summary(lm_model1)
coefficients1 <- summary_lm1$coefficients
slope1 <- round(coefficients1[2, 1], 2)
intercept1 <- round(coefficients1[1, 1], 2)
slope_se1 <- round(coefficients1[2, 2], 3)
intercept_se1 <- round(coefficients1[1, 2], 3)
formula_text3_5 <- paste("y = ", slope1, "x + ", intercept1, " (SE: ", slope_se1, ", ", intercept_se1, ")", sep = "")
# WBL 2024 Report: R Script
# This script produce the following graphs;
#       - Figure ES.6, the same as Figure 3.5
#       - Figure ES.7, the same as Figure 3.17
#       - Figure ES.8, the same as Figure 3.18
### Libraries
library(haven)
library(tidyverse)
library(ggplot2)
library(ggrepel)
library(ggthemes)
### Set Up ----
# Path
## change the path to your computer here
main          <- "C:/Users/wb595552/OneDrive - WBG/Reproducibility package WBL 2024/Reproducibility package_shared"
# Directories
data_path     <- file.path(main, "DataWork/Data")
output_es     <- file.path(main, "Outputs/ExecutiveSummary")
output_c3     <- file.path(main, "Outputs/Chapter3")
### Data Clean Up ----
# Load the dataset
## change the path to your computer here
df            <- read_dta(file.path(data_path, "Final/WBL2024_Legal_Process_EOIndex.dta"))
# create Labels to highlight economies
econ_3_5      <- c("Armenia", "Bahamas, The", "Bahrain", "Bhutain", "Cambodia", "Comoros", "Latvia", "St. Lucia", #largest drop between WBL 1.0 and 2.0 per region
"Afghanistan", "Chile", "Iran, Islamic Rep.", "Italy", "Mauritius", "Panama", "Türkiye", "Viet Nam") #smallest drop between WBL 1.0 and 2.0 per region
econ_3_17     <- c("Bangladesh", "Belize", "Canada", "Jordan", "Kazakhstan", "Sudan", "Taiwan, China", #smallest implementation gap per region
"West Bank and Gaza", "United Kingdom", "Bangladesh", "Singapore", "Iran, Islamic Rep.", #additional countries above 45 degree line, or just not
"Bhutan", "Côte d'Ivoire", "Greece", "San Marino", "Suriname", "Timor-Leste", "United Arab Emirates") #largest implementation gap per region
econ_3_18     <- c("Timor-Leste", "Kosovo", "Italy", "El Salvador", "Morocco", "India", "São Tomé and Príncipe", #max difference between WBL 2.0 Legal and EO per region
"Brunei Darussalam", "Russian Federation", "Slovak Republic", "Iceland", "St. Kitts and Nevis", "Qatar", "Bhutan", "Mauritania") #min difference between WBL 2.0 Legal and EO per region
df$label_3_5  <- ifelse(df$economy %in% econ_3_5, df$economy, NA)
df$label_3_17 <- ifelse(df$economy %in% econ_3_17, df$economy, NA)
df$label_3_18 <- ifelse(df$economy %in% econ_3_18, df$economy, NA)
# order and color regions
df$region     <- gsub("High income: OECD", "OECD: High income", df$region)
desired_order <- c("East Asia & Pacific", "Europe & Central Asia", "OECD: High income",
"Latin America & Caribbean", "Middle East & North Africa", "South Asia", "Sub-Saharan Africa")
df$region     <- factor(df$region, levels = desired_order)
region_colors <- c("East Asia & Pacific" = "green", "Europe & Central Asia" = "blue", "OECD: High income" = "black",
"Latin America & Caribbean" = "red", "Middle East & North Africa" = "navy", "South Asia" = "#ADD8E6",
"Sub-Saharan Africa" = "orange")
### Figure ES.6, the same as Figure 3.5  ----
# region_shapes <- c("East Asia & Pacific" = 5, "Europe & Central Asia" = 17, "OECD: High income" = 3,
#                     "Latin America & Caribbean" = 2, "Middle East & North Africa" = 1, "South Asia" = 15,
#                    "Sub-Saharan Africa" = 16)
lm_model1 <- lm(Legal_Index_old ~ Legal_Index_LegNew, data = df)
summary_lm1 <- summary(lm_model1)
coefficients1 <- summary_lm1$coefficients
slope1 <- round(coefficients1[2, 1], 2)
intercept1 <- round(coefficients1[1, 1], 2)
slope_se1 <- round(coefficients1[2, 2], 3)
intercept_se1 <- round(coefficients1[1, 2], 3)
formula_text3_5 <- paste("y = ", slope1, "x + ", intercept1, sep = "")
ggplot(df, aes(x = Legal_Index_LegNew, y = Legal_Index_old)) +
geom_point(aes(color = region), size = 3, stroke = 1.5) +
geom_abline(slope = 1, intercept = 0, color = "black") +
geom_smooth(method = "lm", se = FALSE, color = "maroon") +
geom_text_repel(aes(label = label_3_5, color = region), max.overlaps = 60) +
scale_color_manual(values = region_colors) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color="black", fill= NA, size = 1),
legend.title = element_blank()) +
scale_x_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
scale_y_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
theme(legend.position = "bottom") +
guides(color = guide_legend(nrow = 3, byrow = TRUE)) +
labs(x = "WBL 2.0 Legal Frameworks Score (0-100)", y = "WBL 1.0 Legal Frameworks Score (0-100)") +
annotate("text", x = 10, y = 90, label = formula_text3_5, color = "maroon", size = 5, hjust = 0)
ggsave(file.path(output_es, "00_Figure_ES_6.png"))
ggsave(file.path(output_c3, "03_Figure_ES_3_5.png"))
# WBL 2024 Report: R Script
# This script produce the following graphs;
#       - Figure ES.6, the same as Figure 3.5
#       - Figure ES.7, the same as Figure 3.17
#       - Figure ES.8, the same as Figure 3.18
### Libraries
library(haven)
library(tidyverse)
library(ggplot2)
library(ggrepel)
library(ggthemes)
### Set Up ----
# Path
## change the path to your computer here
main          <- "C:/Users/wb595552/OneDrive - WBG/Reproducibility package WBL 2024/Reproducibility package_shared"
# Directories
data_path     <- file.path(main, "DataWork/Data")
output_es     <- file.path(main, "Outputs/ExecutiveSummary")
output_c3     <- file.path(main, "Outputs/Chapter3")
### Data Clean Up ----
# Load the dataset
## change the path to your computer here
df            <- read_dta(file.path(data_path, "Final/WBL2024_Legal_Process_EOIndex.dta"))
# create Labels to highlight economies
econ_3_5      <- c("Armenia", "Bahamas, The", "Bahrain", "Bhutain", "Cambodia", "Comoros", "Latvia", "St. Lucia", #largest drop between WBL 1.0 and 2.0 per region
"Afghanistan", "Chile", "Iran, Islamic Rep.", "Italy", "Mauritius", "Panama", "Türkiye", "Viet Nam") #smallest drop between WBL 1.0 and 2.0 per region
econ_3_17     <- c("Bangladesh", "Belize", "Canada", "Jordan", "Kazakhstan", "Sudan", "Taiwan, China", #smallest implementation gap per region
"West Bank and Gaza", "United Kingdom", "Bangladesh", "Singapore", "Iran, Islamic Rep.", #additional countries above 45 degree line, or just not
"Bhutan", "Côte d'Ivoire", "Greece", "San Marino", "Suriname", "Timor-Leste", "United Arab Emirates") #largest implementation gap per region
econ_3_18     <- c("Timor-Leste", "Kosovo", "Italy", "El Salvador", "Morocco", "India", "São Tomé and Príncipe", #max difference between WBL 2.0 Legal and EO per region
"Brunei Darussalam", "Russian Federation", "Slovak Republic", "Iceland", "St. Kitts and Nevis", "Qatar", "Bhutan", "Mauritania") #min difference between WBL 2.0 Legal and EO per region
df$label_3_5  <- ifelse(df$economy %in% econ_3_5, df$economy, NA)
df$label_3_17 <- ifelse(df$economy %in% econ_3_17, df$economy, NA)
df$label_3_18 <- ifelse(df$economy %in% econ_3_18, df$economy, NA)
# order and color regions
df$region     <- gsub("High income: OECD", "OECD: High income", df$region)
desired_order <- c("East Asia & Pacific", "Europe & Central Asia", "OECD: High income",
"Latin America & Caribbean", "Middle East & North Africa", "South Asia", "Sub-Saharan Africa")
df$region     <- factor(df$region, levels = desired_order)
region_colors <- c("East Asia & Pacific" = "green", "Europe & Central Asia" = "blue", "OECD: High income" = "black",
"Latin America & Caribbean" = "red", "Middle East & North Africa" = "navy", "South Asia" = "#ADD8E6",
"Sub-Saharan Africa" = "orange")
### Figure ES.6, the same as Figure 3.5  ----
# region_shapes <- c("East Asia & Pacific" = 5, "Europe & Central Asia" = 17, "OECD: High income" = 3,
#                     "Latin America & Caribbean" = 2, "Middle East & North Africa" = 1, "South Asia" = 15,
#                    "Sub-Saharan Africa" = 16)
lm_model1 <- lm(Legal_Index_old ~ Legal_Index_LegNew, data = df)
summary_lm1 <- summary(lm_model1)
coefficients1 <- summary_lm1$coefficients
slope1 <- round(coefficients1[2, 1], 2)
intercept1 <- round(coefficients1[1, 1], 2)
slope_se1 <- round(coefficients1[2, 2], 3)
intercept_se1 <- round(coefficients1[1, 2], 3)
formula_text3_5 <- paste("y = ", slope1, "x + ", intercept1, sep = "")
ggplot(df, aes(x = Legal_Index_LegNew, y = Legal_Index_old)) +
geom_point(aes(color = region), size = 3, stroke = 1.5) +
geom_abline(slope = 1, intercept = 0, color = "black") +
geom_smooth(method = "lm", se = FALSE, color = "maroon") +
geom_text_repel(aes(label = label_3_5, color = region), max.overlaps = 60) +
scale_color_manual(values = region_colors) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color="black", fill= NA, size = 1),
legend.title = element_blank()) +
scale_x_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
scale_y_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
theme(legend.position = "bottom") +
guides(color = guide_legend(nrow = 3, byrow = TRUE)) +
labs(x = "WBL 2.0 Legal Frameworks Score (0-100)", y = "WBL 1.0 Legal Frameworks Score (0-100)") +
annotate("text", x = 10, y = 90, label = formula_text3_5, color = "maroon", size = 5, hjust = 0)
ggsave(file.path(output_es, "00_Figure_ES_6.png"))
ggsave(file.path(output_c3, "03_Figure_ES_3_5.png"))
### Figure ES.7, the same as Figure 3.17  ----
lm_model2 <- lm(Process_Index ~ Legal_Index_LegNew, data = df)
summary_lm2 <- summary(lm_model2)
coefficients2 <- summary_lm2$coefficients
slope2 <- round(coefficients2[2, 1], 2)
intercept2 <- round(coefficients2[1, 1], 2)
slope_se2 <- round(coefficients2[2, 2], 3)
intercept_se2 <- round(coefficients2[1, 2], 3)
formula_text3_17 <- paste("y = ", slope2, "x ", intercept2, sep = "")
ggplot(df, aes(x = Legal_Index_LegNew, y = Process_Index)) +
geom_point(aes(color = region), size = 3, stroke = 1.5) +
geom_abline(slope = 1, intercept = 0, color = "black") +
geom_smooth(method = "lm", se = FALSE, color = "maroon") +
geom_text_repel(aes(color = region, label = label_3_17), max.overlaps = 60) +
scale_color_manual(values = region_colors) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color="black", fill= NA, size = 1),
legend.title = element_blank()) +
scale_x_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
scale_y_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
theme(legend.position = "bottom") +
guides(color = guide_legend(nrow = 3, byrow = TRUE)) +
labs(x = "WBL 2.0 Legal Frameworks Score (0-100)", y = "Supportive Framework Score (0-100)") +
annotate("text", x = 10, y = 90, label = formula_text3_17, color = "maroon", size = 5, hjust = 0)
ggsave(file.path(output_es, "00_Figure_ES_7.png"))
ggsave(file.path(output_c3, "03_Figure_ES_3_17.png"))
### Figure ES.8, the same as Figure 3.18  ----
lm_model3 <- lm(EO_index ~ Legal_Index_LegNew, data = df)
summary_lm3 <- summary(lm_model3)
coefficients3 <- summary_lm3$coefficients
slope3 <- round(coefficients3[2, 1], 2)
intercept3 <- round(coefficients3[1, 1], 2)
slope_se3 <- round(coefficients3[2, 2], 3)
intercept_se3 <- round(coefficients3[1, 2], 3)
formula_text3_18 <- paste("y = ", slope3, "x + ", intercept3, sep = "")
ggplot(df, aes(x = Legal_Index_LegNew, y = EO_index)) +
geom_point(aes(color = region), size = 3, stroke = 1.5) +
geom_abline(slope = 1, intercept = 0, color = "black") +
geom_smooth(method = "lm", se = FALSE, color = "maroon") +
geom_text_repel(aes(color = region, label = label_3_18), max.overlaps = 60) +
scale_color_manual(values = region_colors) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color="black", fill= NA, size = 1),
legend.title = element_blank()) +
scale_x_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
scale_y_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
theme(legend.position = "bottom") +
guides(color = guide_legend(nrow = 3, byrow = TRUE)) +
labs(x = "WBL 2.0 Legal Frameworks Score (0-100)", y = "WBL 2.0 Expert Opinions Score (0-100)") +
annotate("text", x = 50, y = 10, label = formula_text3_18, color = "maroon", size = 5, hjust = 0)
ggsave(file.path(output_es, "00_Figure_ES_8.png"))
ggsave(file.path(output_c3, "03_Figure_ES_3_18.png"))
# WBL 2024 Report: R Script
# This script produce the following graphs;
#       - Figure ES.6, the same as Figure 3.5
#       - Figure ES.7, the same as Figure 3.17
#       - Figure ES.8, the same as Figure 3.18
### Libraries
library(haven)
library(tidyverse)
library(ggplot2)
library(ggrepel)
library(ggthemes)
### Set Up ----
# Path
## change the path to your computer here
main          <- "C:/Users/wb595552/OneDrive - WBG/Reproducibility package WBL 2024/Reproducibility package_shared"
# Directories
data_path     <- file.path(main, "DataWork/Data")
output_es     <- file.path(main, "Outputs/ExecutiveSummary")
output_c3     <- file.path(main, "Outputs/Chapter3")
### Data Clean Up ----
# Load the dataset
## change the path to your computer here
df            <- read_dta(file.path(data_path, "Final/WBL2024_Legal_Process_EOIndex.dta"))
# create Labels to highlight economies
econ_3_5      <- c("Armenia", "Bahamas, The", "Bahrain", "Bhutain", "Cambodia", "Comoros", "Latvia", "St. Lucia", #largest drop between WBL 1.0 and 2.0 per region
"Afghanistan", "Chile", "Iran, Islamic Rep.", "Italy", "Mauritius", "Panama", "Türkiye", "Viet Nam") #smallest drop between WBL 1.0 and 2.0 per region
econ_3_17     <- c("Bangladesh", "Belize", "Canada", "Jordan", "Kazakhstan", "Sudan", "Taiwan, China", #smallest implementation gap per region
"West Bank and Gaza", "United Kingdom", "Bangladesh", "Singapore", "Iran, Islamic Rep.", #additional countries above 45 degree line, or just not
"Bhutan", "Côte d'Ivoire", "Greece", "San Marino", "Suriname", "Timor-Leste", "United Arab Emirates") #largest implementation gap per region
econ_3_18     <- c("Timor-Leste", "Kosovo", "Italy", "El Salvador", "Morocco", "India", "São Tomé and Príncipe", #max difference between WBL 2.0 Legal and EO per region
"Brunei Darussalam", "Russian Federation", "Slovak Republic", "Iceland", "St. Kitts and Nevis", "Qatar", "Bhutan", "Mauritania") #min difference between WBL 2.0 Legal and EO per region
df$label_3_5  <- ifelse(df$economy %in% econ_3_5, df$economy, NA)
df$label_3_17 <- ifelse(df$economy %in% econ_3_17, df$economy, NA)
df$label_3_18 <- ifelse(df$economy %in% econ_3_18, df$economy, NA)
# order and color regions
df$region     <- gsub("High income: OECD", "OECD: High income", df$region)
desired_order <- c("East Asia & Pacific", "Europe & Central Asia", "OECD: High income",
"Latin America & Caribbean", "Middle East & North Africa", "South Asia", "Sub-Saharan Africa")
df$region     <- factor(df$region, levels = desired_order)
region_colors <- c("East Asia & Pacific" = "green", "Europe & Central Asia" = "blue", "OECD: High income" = "black",
"Latin America & Caribbean" = "red", "Middle East & North Africa" = "navy", "South Asia" = "#ADD8E6",
"Sub-Saharan Africa" = "orange")
### Figure ES.6, the same as Figure 3.5  ----
# region_shapes <- c("East Asia & Pacific" = 5, "Europe & Central Asia" = 17, "OECD: High income" = 3,
#                     "Latin America & Caribbean" = 2, "Middle East & North Africa" = 1, "South Asia" = 15,
#                    "Sub-Saharan Africa" = 16)
lm_model1 <- lm(Legal_Index_old ~ Legal_Index_LegNew, data = df)
summary_lm1 <- summary(lm_model1)
coefficients1 <- summary_lm1$coefficients
slope1 <- round(coefficients1[2, 1], 2)
intercept1 <- round(coefficients1[1, 1], 2)
slope_se1 <- round(coefficients1[2, 2], 3)
intercept_se1 <- round(coefficients1[1, 2], 3)
formula_text3_5 <- paste("y = ", slope1, "x + ", intercept1, sep = "")
ggplot(df, aes(x = Legal_Index_LegNew, y = Legal_Index_old)) +
geom_point(aes(color = region), size = 3, stroke = 1.5) +
geom_abline(slope = 1, intercept = 0, color = "black") +
geom_smooth(method = "lm", se = FALSE, color = "maroon") +
geom_text_repel(aes(label = label_3_5, color = region), max.overlaps = 60) +
scale_color_manual(values = region_colors) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color="black", fill= NA, size = 1),
legend.title = element_blank()) +
scale_x_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
scale_y_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
theme(legend.position = "bottom") +
guides(color = guide_legend(nrow = 3, byrow = TRUE)) +
labs(x = "WBL 2.0 Legal Frameworks Score (0-100)", y = "WBL 1.0 Legal Frameworks Score (0-100)") +
annotate("text", x = 10, y = 90, label = formula_text3_5, color = "maroon", size = 5, hjust = 0)
ggsave(file.path(output_es, "00_Figure_ES_6.png"))
ggsave(file.path(output_c3, "03_Figure_3_5.png"))
### Figure ES.7, the same as Figure 3.17  ----
lm_model2 <- lm(Process_Index ~ Legal_Index_LegNew, data = df)
summary_lm2 <- summary(lm_model2)
coefficients2 <- summary_lm2$coefficients
slope2 <- round(coefficients2[2, 1], 2)
intercept2 <- round(coefficients2[1, 1], 2)
slope_se2 <- round(coefficients2[2, 2], 3)
intercept_se2 <- round(coefficients2[1, 2], 3)
formula_text3_17 <- paste("y = ", slope2, "x ", intercept2, sep = "")
ggplot(df, aes(x = Legal_Index_LegNew, y = Process_Index)) +
geom_point(aes(color = region), size = 3, stroke = 1.5) +
geom_abline(slope = 1, intercept = 0, color = "black") +
geom_smooth(method = "lm", se = FALSE, color = "maroon") +
geom_text_repel(aes(color = region, label = label_3_17), max.overlaps = 60) +
scale_color_manual(values = region_colors) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color="black", fill= NA, size = 1),
legend.title = element_blank()) +
scale_x_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
scale_y_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
theme(legend.position = "bottom") +
guides(color = guide_legend(nrow = 3, byrow = TRUE)) +
labs(x = "WBL 2.0 Legal Frameworks Score (0-100)", y = "Supportive Framework Score (0-100)") +
annotate("text", x = 10, y = 90, label = formula_text3_17, color = "maroon", size = 5, hjust = 0)
ggsave(file.path(output_es, "00_Figure_ES_7.png"))
ggsave(file.path(output_c3, "03_Figure_3_17.png"))
### Figure ES.8, the same as Figure 3.18  ----
lm_model3 <- lm(EO_index ~ Legal_Index_LegNew, data = df)
summary_lm3 <- summary(lm_model3)
coefficients3 <- summary_lm3$coefficients
slope3 <- round(coefficients3[2, 1], 2)
intercept3 <- round(coefficients3[1, 1], 2)
slope_se3 <- round(coefficients3[2, 2], 3)
intercept_se3 <- round(coefficients3[1, 2], 3)
formula_text3_18 <- paste("y = ", slope3, "x + ", intercept3, sep = "")
ggplot(df, aes(x = Legal_Index_LegNew, y = EO_index)) +
geom_point(aes(color = region), size = 3, stroke = 1.5) +
geom_abline(slope = 1, intercept = 0, color = "black") +
geom_smooth(method = "lm", se = FALSE, color = "maroon") +
geom_text_repel(aes(color = region, label = label_3_18), max.overlaps = 60) +
scale_color_manual(values = region_colors) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color="black", fill= NA, size = 1),
legend.title = element_blank()) +
scale_x_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
scale_y_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
theme(legend.position = "bottom") +
guides(color = guide_legend(nrow = 3, byrow = TRUE)) +
labs(x = "WBL 2.0 Legal Frameworks Score (0-100)", y = "WBL 2.0 Expert Opinions Score (0-100)") +
annotate("text", x = 50, y = 10, label = formula_text3_18, color = "maroon", size = 5, hjust = 0)
ggsave(file.path(output_es, "00_Figure_ES_8.png"))
ggsave(file.path(output_c3, "03_Figure_3_18.png"))
# WBL 2024 Report: R Script
# This script produce the following graphs;
#       - Figure ES.6, the same as Figure 3.5
#       - Figure ES.7, the same as Figure 3.17
#       - Figure ES.8, the same as Figure 3.18
### Libraries
library(haven)
library(tidyverse)
library(ggplot2)
library(ggrepel)
library(ggthemes)
### Set Up ----
# Path
## change the path to your computer here
main          <- "C:/Users/wb595552/OneDrive - WBG/Reproducibility package WBL 2024/Reproducibility package_shared"
# Directories
data_path     <- file.path(main, "DataWork/Data")
output_es     <- file.path(main, "Outputs/ExecutiveSummary")
output_c3     <- file.path(main, "Outputs/Chapter3")
### Data Clean Up ----
# Load the dataset
## change the path to your computer here
df            <- read_dta(file.path(data_path, "Final/WBL2024_Legal_Process_EOIndex.dta"))
# create Labels to highlight economies
econ_3_5      <- c("Armenia", "Bahamas, The", "Bahrain", "Bhutain", "Cambodia", "Comoros", "Latvia", "St. Lucia", #largest drop between WBL 1.0 and 2.0 per region
"Afghanistan", "Chile", "Iran, Islamic Rep.", "Italy", "Mauritius", "Panama", "Türkiye", "Viet Nam") #smallest drop between WBL 1.0 and 2.0 per region
econ_3_17     <- c("Bangladesh", "Belize", "Canada", "Jordan", "Kazakhstan", "Sudan", "Taiwan, China", #smallest implementation gap per region
"West Bank and Gaza", "United Kingdom", "Bangladesh", "Singapore", "Iran, Islamic Rep.", #additional countries above 45 degree line, or just not
"Bhutan", "Côte d'Ivoire", "Greece", "San Marino", "Suriname", "Timor-Leste", "United Arab Emirates") #largest implementation gap per region
econ_3_18     <- c("Timor-Leste", "Kosovo", "Italy", "El Salvador", "Morocco", "India", "São Tomé and Príncipe", #max difference between WBL 2.0 Legal and EO per region
"Brunei Darussalam", "Russian Federation", "Slovak Republic", "Iceland", "St. Kitts and Nevis", "Qatar", "Bhutan", "Mauritania") #min difference between WBL 2.0 Legal and EO per region
df$label_3_5  <- ifelse(df$economy %in% econ_3_5, df$economy, NA)
df$label_3_17 <- ifelse(df$economy %in% econ_3_17, df$economy, NA)
df$label_3_18 <- ifelse(df$economy %in% econ_3_18, df$economy, NA)
# order and color regions
df$region     <- gsub("High income: OECD", "OECD: High income", df$region)
desired_order <- c("East Asia & Pacific", "Europe & Central Asia", "OECD: High income",
"Latin America & Caribbean", "Middle East & North Africa", "South Asia", "Sub-Saharan Africa")
df$region     <- factor(df$region, levels = desired_order)
region_colors <- c("East Asia & Pacific" = "green", "Europe & Central Asia" = "blue", "OECD: High income" = "black",
"Latin America & Caribbean" = "red", "Middle East & North Africa" = "navy", "South Asia" = "#ADD8E6",
"Sub-Saharan Africa" = "orange")
### Figure ES.6, the same as Figure 3.5  ----
# region_shapes <- c("East Asia & Pacific" = 5, "Europe & Central Asia" = 17, "OECD: High income" = 3,
#                     "Latin America & Caribbean" = 2, "Middle East & North Africa" = 1, "South Asia" = 15,
#                    "Sub-Saharan Africa" = 16)
lm_model1 <- lm(Legal_Index_old ~ Legal_Index_LegNew, data = df)
summary_lm1 <- summary(lm_model1)
coefficients1 <- summary_lm1$coefficients
slope1 <- round(coefficients1[2, 1], 2)
intercept1 <- round(coefficients1[1, 1], 2)
slope_se1 <- round(coefficients1[2, 2], 3)
intercept_se1 <- round(coefficients1[1, 2], 3)
formula_text3_5 <- paste("y = ", slope1, "x + ", intercept1, sep = "")
ggplot(df, aes(x = Legal_Index_LegNew, y = Legal_Index_old)) +
geom_point(aes(color = region), size = 3, stroke = 1.5) +
geom_abline(slope = 1, intercept = 0, color = "black") +
geom_smooth(method = "lm", se = FALSE, color = "maroon") +
geom_text_repel(aes(label = label_3_5, color = region), max.overlaps = 60) +
scale_color_manual(values = region_colors) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color="black", fill= NA, size = 1),
legend.title = element_blank()) +
scale_x_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
scale_y_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
theme(legend.position = "bottom") +
guides(color = guide_legend(nrow = 3, byrow = TRUE)) +
labs(x = "WBL 2.0 Legal Frameworks Score (0-100)", y = "WBL 1.0 Legal Frameworks Score (0-100)") +
annotate("text", x = 10, y = 90, label = formula_text3_5, color = "maroon", size = 5, hjust = 0)
ggsave(file.path(output_es, "00_Figure_ES_6.png"))
ggsave(file.path(output_c3, "03_Figure_3_5.png"))
### Figure ES.7, the same as Figure 3.17  ----
lm_model2 <- lm(Process_Index ~ Legal_Index_LegNew, data = df)
summary_lm2 <- summary(lm_model2)
coefficients2 <- summary_lm2$coefficients
slope2 <- round(coefficients2[2, 1], 2)
intercept2 <- round(coefficients2[1, 1], 2)
slope_se2 <- round(coefficients2[2, 2], 3)
intercept_se2 <- round(coefficients2[1, 2], 3)
formula_text3_17 <- paste("y = ", slope2, "x ", intercept2, sep = "")
ggplot(df, aes(x = Legal_Index_LegNew, y = Process_Index)) +
geom_point(aes(color = region), size = 3, stroke = 1.5) +
geom_abline(slope = 1, intercept = 0, color = "black") +
geom_smooth(method = "lm", se = FALSE, color = "maroon") +
geom_text_repel(aes(color = region, label = label_3_17), max.overlaps = 60) +
scale_color_manual(values = region_colors) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color="black", fill= NA, size = 1),
legend.title = element_blank()) +
scale_x_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
scale_y_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
theme(legend.position = "bottom") +
guides(color = guide_legend(nrow = 3, byrow = TRUE)) +
labs(x = "WBL 2.0 Legal Frameworks Score (0-100)", y = "Supportive Framework Score (0-100)") +
annotate("text", x = 10, y = 90, label = formula_text3_17, color = "maroon", size = 5, hjust = 0)
ggsave(file.path(output_es, "00_Figure_ES_7.png"))
ggsave(file.path(output_c3, "03_Figure_3_17.png"))
### Figure ES.8, the same as Figure 3.18  ----
lm_model3 <- lm(EO_index ~ Legal_Index_LegNew, data = df)
summary_lm3 <- summary(lm_model3)
coefficients3 <- summary_lm3$coefficients
slope3 <- round(coefficients3[2, 1], 2)
intercept3 <- round(coefficients3[1, 1], 2)
slope_se3 <- round(coefficients3[2, 2], 3)
intercept_se3 <- round(coefficients3[1, 2], 3)
formula_text3_18 <- paste("y = ", slope3, "x + ", intercept3, sep = "")
ggplot(df, aes(x = Legal_Index_LegNew, y = EO_index)) +
geom_point(aes(color = region), size = 3, stroke = 1.5) +
geom_abline(slope = 1, intercept = 0, color = "black") +
geom_smooth(method = "lm", se = FALSE, color = "maroon") +
geom_text_repel(aes(color = region, label = label_3_18), max.overlaps = 60) +
scale_color_manual(values = region_colors) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color="black", fill= NA, size = 1),
legend.title = element_blank()) +
scale_x_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
scale_y_continuous(breaks = seq(0, 100, 20), limits = c(0, 100)) +
theme(legend.position = "bottom") +
guides(color = guide_legend(nrow = 3, byrow = TRUE)) +
labs(x = "WBL 2.0 Legal Frameworks Score (0-100)", y = "WBL 2.0 Expert Opinions Score (0-100)") +
annotate("text", x = 50, y = 10, label = formula_text3_18, color = "maroon", size = 5, hjust = 0)
ggsave(file.path(output_es, "00_Figure_ES_8.png"))
ggsave(file.path(output_c3, "03_Figure_3_18.png"))
